from sys import exit

try:
    rom = open("data-vwf.bin", "rb")
except IOError:
    print "<!> Cannot open data file;"
    exit(-1)

try:
    out = open("vwf-big.txt", "w")
except IOError:
    print "<!> Cannot write output file;"
    exit(-1)
else:
    print "<i> Extracion begin;"

###---


for y in xrange(128):
    mask = 0
    for x in xrange(16):
        mask = mask | (ord(rom.read(1)) | ord(rom.read(1)));


    w = 8;
    if(mask):
        while(not (mask & 1)):
            mask = mask >> 1
            w = w - 1
    else:
        w = 0

    out.write("$%02i," % w)
    
        
###---
print "<i> Done;"
rom.close()
out.close()
